/**
 * 
 */
package cn.hma.jftpl.run;

import org.beetl.ext.jfinal.BeetlRenderFactory;

import cn.hma.jftpl.controller.FilmController;
import cn.hma.jftpl.controller.IndexController;
import cn.hma.jftpl.model.Film;

import com.jfinal.config.Constants;
import com.jfinal.config.Handlers;
import com.jfinal.config.Interceptors;
import com.jfinal.config.JFinalConfig;
import com.jfinal.config.Plugins;
import com.jfinal.config.Routes;
import com.jfinal.core.JFinal;
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.jfinal.plugin.druid.DruidPlugin;

/**
 * @author hm
 *
 */
public class Config extends JFinalConfig {

	/**
	 * @param args
	 */

	@Override
	public void configConstant(Constants me) {
		me.setDevMode(true);
		me.setMainRenderFactory(new BeetlRenderFactory());
		me.setBaseViewPath("/WEB-INF/views");
	}

	@Override
	public void configRoute(Routes me) {
		me.add("/", IndexController.class);
		me.add("/film", FilmController.class);

	}

	@Override
	public void configPlugin(Plugins me) {
		DruidPlugin dp = new DruidPlugin("jdbc:mysql://127.0.0.1/webixdb?characterEncoding=utf8", "root", "");
		me.add(dp);
		ActiveRecordPlugin arp = new ActiveRecordPlugin(dp);
		arp.addMapping("films", Film.class);
		me.add(arp);

	}

	@Override
	public void configInterceptor(Interceptors me) {
		// TODO Auto-generated method stub

	}

	@Override
	public void configHandler(Handlers me) {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		JFinal.start("WebRoot", 8080, "/", 2);
	}

}
